<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script src="/jquery/dist/jquery.min.js"></script>
    <script src="/bootstrap/dist/js/bootstrap.min.js"></script>
<script th:inline="javascript">
    $(function () {
        var data =[[${user}]];

        $("#logout").click(function () {
            window.location.href='/logout';
        });
        $("#touserlist").click(function () {
            window.location.href='/user/userList?page=1';
        });
    });
    function touserlist() {

    var url = '/user/userList'
    $.ajax({
        type: 'POST',
        url: url,
        dataType: 'json',
        data: {page: 1},
        cache: false,
        success: function (data) {

            var code = data.code;
            var msg = data.msg;
            if (code == '1') {
                console.log(JSON.stringify(data))
//                window.location.href='/index';
            } else {
                alert('错误信息: '+msg);
            }
        },
        error: function (data) {
            console.log(JSON.stringify(data))
            var code = data.code;
            var msg = data.msg;
            alert('错误信息: '+msg);
        }
    });
    }
    function logout() {
        window.location.href='/logout';
    }
</script>
</head>
<body>
    <div>这是首页</div>
    <span shiro:authenticated="true" >
          <span>欢迎您：<span th:text="${user}"></span></span>
    </span>
<hr/>
    <button type="button" id="logout" > 退出 </button>

    <button type="button" id="touserlist" >用户列表</button>
</body>
</html>